<?php
namespace Admin\Controller;
use Think\Controller;
class GroupController extends CommonController {
    public function index() {
        $group = M('Group');
        if (IS_AJAX) {
            $name = I('name', '', 'htmlspecialchars');
            $id = I('id', 0, 'intval');
            $where['id'] = $id;

            if ($group->where($where)->setField(['name'=>$name, 'update_time' => NOW_TIME]) !== false) {
                $this->ajaxReturn(V(1, '修改成功'));
            } else {
                $this->ajaxReturn(V(0, '修改失败'));
            }
        }

        $info = $group->field(true)->find();
        $this->assign('info', $info);
        $this->display();
    }
}